package com.bree.erp.report.vo;


import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import com.bree.erp.entity.ItemRequest;
import com.bree.erp.entity.PurchaseRequisition;

public class PurchaseRequisitionData {
	
	private PurchaseRequisition purchaseRequisition;
	private List<ItemRequestData> items;
	
	public PurchaseRequisitionData(PurchaseRequisition purchaseRequisition) {
		
		this.purchaseRequisition = purchaseRequisition;
		
		Collection<ItemRequest> requests = purchaseRequisition.getRequests();
		if(requests == null) {
			items = Collections.emptyList();
		}
		
		
		items = new ArrayList<ItemRequestData>(); 
		
		int count = 0;
		for(ItemRequest item : requests) {
			items.add(new ItemRequestData(++count, item));
		}
		
	}
	
	// report specifics
	
	public String getProjectName() {		
		return purchaseRequisition.getProject() == null ? null : purchaseRequisition.getProject().getDescription();
	}
	
	public String getOwnerName() {
		
		return null; // TODO: purchaseRequisition.getPreparedBy() == null ? null : purchaseRequisition.getPreparedBy().getDisplayName();
		
	}
	
	public String getApproverName() {
		
		return null; // TODO: purchaseRequisition.getApprovedBy() == null ? null : purchaseRequisition.getApprovedBy().getDisplayName();
		
	}
	
	public Collection<ItemRequestData> getItems() {
		
		return items;
	}
	
	public String getDescription() {
		return purchaseRequisition.getDescription();
	}
	
	public Date getRequisitionDate() {
		return purchaseRequisition.getRequisitionDate();
	}
	
	public String getStatus() {
		return purchaseRequisition.getStatus() == null ? null : purchaseRequisition.getStatus().toString();
	}

	
}
